# -*- coding: utf-8 -*-
__author__ = 'lztkdr'
__date__ = '2020/11/27 13:45'

"""
@property用来在类中定义规则，并且外部简单调用#
@property用来在类中定义规则，并且外部简单调用，即外部实例话后，不用调用方法来设置属性，而是直接设置属性
"""


class Student(object):

	@property
	def score(self):
		return self._score

	@score.setter
	def score(self, value):
		if not isinstance(value, int):
			raise ValueError('score must be an integer!')
		if value < 0 or value > 100:
			raise ValueError('score must between 0 ~ 100!')
		self._score = value


if __name__ == "__main__":
	stu = Student()
	stu.score = 100
	print(stu.score)
	stu.score = 1000
